﻿/*功能描述：客户设置
作者：李周蓬
时间：2021-12-07
修改人：李周蓬
修改时间：2021-12-07*/
using Dapper;
using HongStone.Domain.ClientManagementModel;
using HongStone.Dto;
using HongStone.Ince.IClient;
using Microsoft.Extensions.Configuration;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace HongStone.Repository
{
    public class CustomerDal: ICustomer
    {
        private readonly HongStoneContext _hongStoneContext;
        private readonly IConfiguration _configuration;
        public CustomerDal(HongStoneContext hongStoneContext, IConfiguration configuration)
        {
            _hongStoneContext = hongStoneContext;
            _configuration = configuration;
        }
        /// <summary>
        /// 添加甲方负责人
        /// </summary>
        /// <param name="responsiblePerson"></param>
        /// <returns></returns>
        public ResultData AddResponsiblePerson(ResponsiblePerson responsiblePerson)
        {
            _hongStoneContext.Add(responsiblePerson);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 添加满意度调查
        /// </summary>
        /// <param name="satisfactionSurvey"></param>
        /// <returns></returns>
        public ResultData AddSatisfactionSurvey(SatisfactionSurvey satisfactionSurvey)
        {
            _hongStoneContext.Add(satisfactionSurvey);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }

        //public ResultData ShowManYiDu(string manyidu)
        //{
        //    var query = _hongStoneContext.dictionariesTables.Where(m => m.DictionariesClass == manyidu);
        //    return new ResultData() { Code = 1, Data = query };
        //}
        /// <summary>
        /// 显示字典表
        /// </summary>
        /// <returns></returns>
        public ResultData ShowManYiDu()
        {
            var query = _hongStoneContext.dictionariesTables.AsQueryable();
            return new ResultData() { Code = 1, Data = query };
        }
        /// <summary>
        /// 绑定省市县
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResultData BindCity(int id)
        {
            var list = _hongStoneContext.customerCitys.Where(m => m.PId == id).ToList();
            return new ResultData() { Code = 1, Data = list };
        }
        /// <summary>
        /// 添加基本信息
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ResultData AddEntering(Customer customer)
        {
            _hongStoneContext.Add(customer);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 添加扩展信息
        /// </summary>
        /// <param name="extendInformation"></param>
        /// <returns></returns>
        public ResultData AddEnterings(ExtendInformation extendInformation)
        {
            _hongStoneContext.Add(extendInformation);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 添加附件
        /// </summary>
        /// <param name="accessory"></param>
        /// <returns></returns>
        public ResultData AddFile(Accessory accessory)
        {
            _hongStoneContext.Add(accessory);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 显示录入列表
        /// </summary>
        /// <param name="checkDto"></param>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="totalcount"></param>
        /// <returns></returns>
        public ResultData ShowList(int pageindex, int pagesize,CheckDto checkDto,out int totalcount)
        {
            using (var conn = new SqlConnection(_configuration.GetConnectionString("MSSQL")))
            {
                var query = $"select *,f.DictionariesName as CooperationName,c.CName as CountryName,d.CName as ProvinceName,e.CName as CityName,g.DictionariesName as CreditRatingsName,h.DictionariesName as IndustyName,i.DictionariesName as IntimacyName,j.DictionariesName as TypeName from Customer a join ExtendInformation b on a.CustomerSerialNumber=b.CustomerSerialNumber join CustomerCity c on b.CountryId=c.CId join CustomerCity d on b.ProvinceId=d.CId join CustomerCity e on b.CityId=e.CId join DictionariesTable f on b.Cooperation=f.DictionariesId join DictionariesTable g on b.CreditRatingsId=g.DictionariesId join DictionariesTable h on b.IndustyId=h.DictionariesId join DictionariesTable i on b.IntimacyId=i.DictionariesId join DictionariesTable j on b.TypeId=j.DictionariesId where 1=1  ";
                
                if (!string.IsNullOrWhiteSpace(checkDto.CustomerName) && checkDto.CustomerName != "string")
                {
                    query += $" and a.CustomerName='{checkDto.CustomerName}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.CustomerSerialNumber) && checkDto.CustomerSerialNumber != "string")
                {
                    query += $" and a.CustomerSerialNumber='{checkDto.CustomerSerialNumber}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.CustomerReferred) && checkDto.CustomerReferred != "string")
                {
                    query += $" and a.CustomerReferred='{checkDto.CustomerReferred}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.CompanyAddress) && checkDto.CompanyAddress != "string")
                {
                    query += $" and a.CompanyAddress='{checkDto.CompanyAddress}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.PostalCode) && checkDto.PostalCode != "string")
                {
                    query += $" and a.PostalCode='{checkDto.PostalCode}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.Linkman) && checkDto.Linkman != "string")
                {
                    query += $" and a.Linkman='{checkDto.Linkman}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.CompanyTel) && checkDto.CompanyTel != "string")
                {
                    query += $" and a.CompanyTel='{checkDto.CompanyTel}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.FaxNumber) && checkDto.FaxNumber != "string")
                {
                    query += $" and a.FaxNumber='{checkDto.FaxNumber}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.EnglishName) && checkDto.EnglishName != "string")
                {
                    query += $" and b.EnglishName='{checkDto.EnglishName}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.CountryName) && checkDto.FaxNumber != "string")
                {
                    query += $" and b.CountryName='{checkDto.CountryName}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.ProvinceName) && checkDto.EnglishName != "string")
                {
                    query += $" and b.ProvinceName='{checkDto.ProvinceName}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.CityName) && checkDto.EnglishName != "string")
                {
                    query += $" and b.CityName='{checkDto.CityName}'";
                }
                if (checkDto.Cooperation > 0)
                {
                    query += $" and b.Cooperation='{checkDto.Cooperation}'";
                }
                if (checkDto.TypeId > 0)
                {
                    query += $" and b.TypeId='{checkDto.TypeId}'";
                }
                if (checkDto.IndustyId > 0)
                {
                    query += $" and b.IndustyId='{checkDto.IndustyId}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.Embranchment) && checkDto.Embranchment != "string")
                {
                    query += $" and b.Embranchment='{checkDto.Embranchment}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.Email) && checkDto.Email != "string")
                {
                    query += $" and b.Email='{checkDto.Email}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.HomePage) && checkDto.HomePage != "string")
                {
                    query += $" and b.HomePage='{checkDto.HomePage}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.RelationDepartment) && checkDto.RelationDepartment != "string")
                {
                    query += $" and b.RelationDepartment='{checkDto.RelationDepartment}'";
                }
                if (checkDto.CreditRatingsId > 0)
                {
                    query += $" and b.CreditRatingsId='{checkDto.CreditRatingsId}'";
                }
                if (checkDto.IntimacyId > 0)
                {
                    query += $" and b.IntimacyId='{checkDto.IntimacyId}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.BankName) && checkDto.BankName != "string")
                {
                    query += $" and b.BankName='{checkDto.BankName}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.BankAccount) && checkDto.BankAccount != "string")
                {
                    query += $" and b.BankAccount='{checkDto.BankAccount}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.EnterpriseCode) && checkDto.EnterpriseCode != "string")
                {
                    query += $" and b.EnterpriseCode='{checkDto.EnterpriseCode}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.Member) && checkDto.Member != "string")
                {
                    query += $" and b.Member='{checkDto.Member}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.TaxpayerCode) && checkDto.TaxpayerCode != "string")
                {
                    query += $" and b.TaxpayerCode='{checkDto.TaxpayerCode}'";
                }
                if (!string.IsNullOrWhiteSpace(checkDto.Remark) && checkDto.Remark != "string")
                {
                    query += $" and b.Remark='{checkDto.Remark}'";
                }
                var list = conn.Query<CustomerDto>(query).ToList();
                totalcount = list.Count();
                list = list.OrderBy(m => m.CustomerId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
                return new ResultData() { Code = 1, Data = list,TotalCount=totalcount };
            }

            //var query = from a in _hongStoneContext.customers
            //            join b in _hongStoneContext.extendInformations on a.CustomerId equals b.CustomerId
            //            join c in _hongStoneContext.customerCitys on b.CountryId equals c.CId
            //            join d in _hongStoneContext.customerCitys on b.ProvinceId equals d.CId
            //            join e in _hongStoneContext.customerCitys on b.CityId equals e.CId
            //            join f in _hongStoneContext.dictionariesTables on b.Cooperation equals f.DictionariesId
            //            join g in _hongStoneContext.dictionariesTables on b.CreditRatingsId equals g.DictionariesId
            //            join i in _hongStoneContext.dictionariesTables on b.IndustyId equals i.DictionariesId
            //            join j in _hongStoneContext.dictionariesTables on b.IntimacyId equals j.DictionariesId
            //            join k in _hongStoneContext.dictionariesTables on b.TypeId equals k.DictionariesId
            //            select new CustomerDto
            //            {
            //                CustomerId = a.CustomerId,
            //                CustomerName = a.CustomerName,
            //                CustomerReferred = a.CustomerReferred,
            //                CustomerSerialNumber = a.CustomerSerialNumber,
            //                CompanyAddress = a.CompanyAddress,
            //                PostalCode = a.PostalCode,
            //                Linkman = a.Linkman,
            //                CompanyTel = a.CompanyTel,
            //                FaxNumber = a.FaxNumber,
            //                EnglishName = b.EnglishName,
            //                Cooperation = b.Cooperation,
            //                CountryId = c.CId,
            //                CountryName = c.CName,
            //                ProvinceId = d.CId,
            //                ProvinceName = d.CName,
            //                CityId = e.CId,
            //                CityName = e.CName,
            //                TypeId = b.TypeId,
            //                IndustyId = b.IndustyId,
            //                Embranchment = b.Embranchment,
            //                HomePage = b.HomePage,
            //                RelationDepartment = b.RelationDepartment,
            //                RelationTime = b.RelationTime,
            //                CreditRatingsId = b.CreditRatingsId,
            //                IntimacyId = b.IntimacyId,
            //                BankName = b.BankName,
            //                BankAccount = b.BankAccount,
            //                EnterpriseCode = b.EnterpriseCode,
            //                Member = b.Member,
            //                TaxpayerCode = b.TaxpayerCode,
            //                Remark = b.Remark,
            //                CooperationName = f.DictionariesName,
            //                IndustyName = i.DictionariesName,
            //                IntimacyName = j.DictionariesName,
            //                TypeName = k.DictionariesName,
            //                CreditRatingsName = g.DictionariesName,
            //                Email = b.Email
            //            };
            //if(!string.IsNullOrWhiteSpace(checkDto.CustomerName)&& checkDto.CustomerName!="string")
            //{
            //    query = query.Where(m => m.CustomerName.Contains(checkDto.CustomerName));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.CustomerSerialNumber) && checkDto.CustomerSerialNumber != "string")
            //{
            //    query = query.Where(m => m.CustomerSerialNumber.Contains(checkDto.CustomerSerialNumber));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.CustomerReferred) && checkDto.CustomerReferred != "string")
            //{
            //    query = query.Where(m => m.CustomerReferred.Contains(checkDto.CustomerReferred));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.CompanyAddress) && checkDto.CompanyAddress != "string")
            //{
            //    query = query.Where(m => m.CompanyAddress.Contains(checkDto.CompanyAddress));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.PostalCode) && checkDto.PostalCode != "string")
            //{
            //    query = query.Where(m => m.PostalCode.Contains(checkDto.PostalCode));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.Linkman) && checkDto.Linkman != "string")
            //{
            //    query = query.Where(m => m.Linkman.Contains(checkDto.Linkman));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.CompanyTel) && checkDto.CompanyTel != "string")
            //{
            //    query = query.Where(m => m.CompanyTel.Contains(checkDto.CompanyTel));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.FaxNumber) && checkDto.FaxNumber != "string")
            //{
            //    query = query.Where(m => m.FaxNumber.Contains(checkDto.FaxNumber));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.EnglishName) && checkDto.EnglishName != "string")
            //{
            //    query = query.Where(m => m.EnglishName.Contains(checkDto.EnglishName));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.CountryName) && checkDto.FaxNumber != "string")
            //{
            //    query = query.Where(m => m.CountryName.Contains(checkDto.CountryName));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.ProvinceName) && checkDto.EnglishName != "string")
            //{
            //    query = query.Where(m => m.ProvinceName.Contains(checkDto.ProvinceName));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.CityName) && checkDto.EnglishName != "string")
            //{
            //    query = query.Where(m => m.CityName.Contains(checkDto.CityName));
            //}
            //if (checkDto.Cooperation>0)
            //{
            //    query = query.Where(m => m.Cooperation==(checkDto.Cooperation));
            //}
            //if (checkDto.TypeId > 0)
            //{
            //    query = query.Where(m => m.TypeId == (checkDto.TypeId));
            //}
            //if (checkDto.IndustyId > 0)
            //{
            //    query = query.Where(m => m.IndustyId == (checkDto.IndustyId));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.Embranchment) && checkDto.Embranchment != "string")
            //{
            //    query = query.Where(m => m.Embranchment.Contains(checkDto.Embranchment));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.Email) && checkDto.Email != "string")
            //{
            //    query = query.Where(m => m.Email.Contains(checkDto.Email));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.HomePage) && checkDto.HomePage != "string")
            //{
            //    query = query.Where(m => m.HomePage.Contains(checkDto.HomePage));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.RelationDepartment) && checkDto.RelationDepartment != "string")
            //{
            //    query = query.Where(m => m.RelationDepartment.Contains(checkDto.RelationDepartment));
            //}
            //if (checkDto.CreditRatingsId > 0)
            //{
            //    query = query.Where(m => m.CreditRatingsId == (checkDto.CreditRatingsId));
            //}
            //if (checkDto.IntimacyId > 0)
            //{
            //    query = query.Where(m => m.IntimacyId == (checkDto.IntimacyId));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.BankName) && checkDto.BankName != "string")
            //{
            //    query = query.Where(m => m.BankName.Contains(checkDto.BankName));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.BankAccount) && checkDto.BankAccount != "string")
            //{
            //    query = query.Where(m => m.BankAccount.Contains(checkDto.BankAccount));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.EnterpriseCode) && checkDto.EnterpriseCode != "string")
            //{
            //    query = query.Where(m => m.EnterpriseCode.Contains(checkDto.EnterpriseCode));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.Member) && checkDto.Member != "string")
            //{
            //    query = query.Where(m => m.Member.Contains(checkDto.Member));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.TaxpayerCode) && checkDto.TaxpayerCode != "string")
            //{
            //    query = query.Where(m => m.TaxpayerCode.Contains(checkDto.TaxpayerCode));
            //}
            //if (!string.IsNullOrWhiteSpace(checkDto.Remark) && checkDto.Remark != "string")
            //{
            //    query = query.Where(m => m.Remark.Contains(checkDto.Remark));
            //}
            ////if(checkDto.beginRelationTime!=null)
            ////{
            ////    query = query.Where(m => m.RelationTime >= checkDto.beginRelationTime);
            ////}
            ////if (checkDto.endRelationTime != null)
            ////{
            ////    query = query.Where(m => m.RelationTime >= checkDto.endRelationTime);
            ////}
            //totalcount = query.Count();
            //var liet = query.OrderBy(m => m.CustomerId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
            //return new ResultData() { Code = 1, TotalCount = totalcount, Data = liet };
            
        }
        /// <summary>
        /// 显示列表
        /// </summary>
        /// <returns></returns>
        public ResultData ShowLie()
        {
            var query = from a in _hongStoneContext.customers
                        join b in _hongStoneContext.extendInformations on a.CustomerId equals b.CustomerId
                        join c in _hongStoneContext.customerCitys on b.CountryId equals c.CId
                        join d in _hongStoneContext.customerCitys on b.ProvinceId equals d.CId
                        join e in _hongStoneContext.customerCitys on b.CityId equals e.CId
                        select new CustomerDto
                        {
                            CustomerId = a.CustomerId,
                            CustomerName = a.CustomerName,
                            CustomerReferred = a.CustomerReferred,
                            CustomerSerialNumber = a.CustomerSerialNumber,
                            CompanyAddress = a.CompanyAddress,
                            PostalCode = a.PostalCode,
                            Linkman = a.Linkman,
                            CompanyTel = a.CompanyTel,
                            FaxNumber = a.FaxNumber,
                            EnglishName = b.EnglishName,
                            Cooperation = b.Cooperation,
                            CountryId = c.CId,
                            CountryName = c.CName,
                            ProvinceId = d.CId,
                            ProvinceName = d.CName,
                            CityId = e.CId,
                            CityName = e.CName,
                            TypeId = b.TypeId,
                            IndustyId = b.IndustyId,
                            Embranchment = b.Embranchment,
                            HomePage = b.HomePage,
                            RelationDepartment = b.RelationDepartment,
                            RelationTime = b.RelationTime,
                            CreditRatingsId = b.CreditRatingsId,
                            IntimacyId = b.IntimacyId,
                            BankName = b.BankName,
                            BankAccount = b.BankAccount,
                            EnterpriseCode = b.EnterpriseCode,
                            Member = b.Member,
                            TaxpayerCode = b.TaxpayerCode,
                            Remark = b.Remark
                        };
            var list= query.ToList();
            return new ResultData() { Code = 1, Data = list };
        }
        /// <summary>
        /// 批量删除客户基本信息
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ResultData Del(string ids)
        {
            var id= ids.Split(',');
            foreach (var item in id)
            {
                var obj = _hongStoneContext.customers.FirstOrDefault(m => m.CustomerSerialNumber == item);
                if (obj != null)
                {
                    _hongStoneContext.customers.Remove(obj);
                }
            }
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 批量删除客户扩展信息
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ResultData Dels(string ids)
        {
            var id = ids.Split(',');
            foreach (var item in id)
            {
                var obj = _hongStoneContext.extendInformations.FirstOrDefault(m => m.CustomerSerialNumber == item);
                if (obj != null)
                {
                    _hongStoneContext.extendInformations.Remove(obj);
                }
            }
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 显示甲方负责人
        /// </summary>
        /// <returns></returns>
        public ResultData ShowJia()
        {
            var list = _hongStoneContext.responsiblePersons.AsQueryable();
            return new ResultData() { Code = 1, Data = list };
        }
        /// <summary>
        /// 显示满意度调查
        /// </summary>
        /// <returns></returns>
        public ResultData ShowMan()
        {
            var list = _hongStoneContext.satisfactionSurveys.AsQueryable();
            return new ResultData() { Code = 1, Data = list };
        }
        /// <summary>
        /// 修改客户基本信息
        /// </summary>
        /// <param name="customer"></param>
        /// <returns></returns>
        public ResultData UpdateCustomer(Customer customer)
        {
            _hongStoneContext.Entry(customer).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return new ResultData() { Code = _hongStoneContext.SaveChanges()};
        }
        /// <summary>
        /// 修改客户扩展信息
        /// </summary>
        /// <param name="extendInformation"></param>
        /// <returns></returns>
        public ResultData UpdateExtendInformation(ExtendInformation extendInformation)
        {
            _hongStoneContext.Entry(extendInformation).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 删除甲方负责人
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResultData DelJia(string id)
        {
            var kk=_hongStoneContext.responsiblePersons.Where(m => m.SerialNumber == id).FirstOrDefault();
            _hongStoneContext.responsiblePersons.Remove(kk);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 删除满意度调查
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ResultData DelMan(string id)
        {
            var kk = _hongStoneContext.satisfactionSurveys.Where(m => m.SatisfactionSurveySerialNumber == id).FirstOrDefault();
            _hongStoneContext.satisfactionSurveys.Remove(kk);
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 修改甲方负责人
        /// </summary>
        /// <param name="responsiblePerson"></param>
        /// <returns></returns>
        public ResultData UpdateJia(ResponsiblePerson responsiblePerson)
        {
            _hongStoneContext.Entry(responsiblePerson).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 修改满意度调查
        /// </summary>
        /// <param name="satisfactionSurvey"></param>
        /// <returns></returns>
        public ResultData UpdateMan(SatisfactionSurvey satisfactionSurvey)
        {
            _hongStoneContext.Entry(satisfactionSurvey).State = Microsoft.EntityFrameworkCore.EntityState.Modified;
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 联系人信息的显示查询分页
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="name"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <returns></returns>
        public ResultData ShowJiaPage(int pageindex, int pagesize, string name, DateTime? beginTime, DateTime? endTime, out int totalcount)
        {
            using (var conn = new SqlConnection(_configuration.GetConnectionString("MSSQL")))
            {
                var query = $"select *,f.DictionariesName as CooperationName,c.CName as CountryName,d.CName as ProvinceName,e.CName as CityName,g.DictionariesName as CreditRatingsName,h.DictionariesName as IndustyName,i.DictionariesName as IntimacyName,j.DictionariesName as TypeName from Customer a join ExtendInformation b on a.CustomerSerialNumber=b.CustomerSerialNumber join CustomerCity c on b.CountryId=c.CId join CustomerCity d on b.ProvinceId=d.CId join CustomerCity e on b.CityId=e.CId join DictionariesTable f on b.Cooperation=f.DictionariesId join DictionariesTable g on b.CreditRatingsId=g.DictionariesId join DictionariesTable h on b.IndustyId=h.DictionariesId join DictionariesTable i on b.IntimacyId=i.DictionariesId join DictionariesTable j on b.TypeId=j.DictionariesId join ResponsiblePerson k on b.SerialNumber=k.SerialNumber where 1=1  ";
                if (!string.IsNullOrWhiteSpace(name))
                {
                    query += $" and k.PersonName='{name}'";
                }
                if (beginTime != null)
                {
                    query += $" and k.PersonName>='{beginTime}'";
                }
                if (endTime != null)
                {
                    query += $" and k.PersonName<='{endTime}'";
                }
                
                var list = conn.Query<ResponsiblePersonDto>(query).ToList();
                totalcount = list.Count();
                list = list.OrderBy(m => m.SerialNumber).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
                return new ResultData() { Code = 1, Data = list, TotalCount = totalcount };
            }

            //    var query = from a in _hongStoneContext.customers
            //            join b in _hongStoneContext.extendInformations on a.CustomerId equals b.CustomerId
            //            join c in _hongStoneContext.customerCitys on b.CountryId equals c.CId
            //            join d in _hongStoneContext.customerCitys on b.ProvinceId equals d.CId
            //            join e in _hongStoneContext.customerCitys on b.CityId equals e.CId
            //            join f in _hongStoneContext.dictionariesTables on b.Cooperation equals f.DictionariesId
            //            join g in _hongStoneContext.dictionariesTables on b.CreditRatingsId equals g.DictionariesId
            //            join i in _hongStoneContext.dictionariesTables on b.IndustyId equals i.DictionariesId
            //            join j in _hongStoneContext.dictionariesTables on b.IntimacyId equals j.DictionariesId
            //            join k in _hongStoneContext.dictionariesTables on b.TypeId equals k.DictionariesId
            //            join l in _hongStoneContext.responsiblePersons on b.SerialNumber equals l.SerialNumber
            //            select new ResponsiblePersonDto
            //            {
            //                CustomerId = a.CustomerId,
            //                CustomerName = a.CustomerName,
            //                CustomerReferred = a.CustomerReferred,
            //                CustomerSerialNumber = a.CustomerSerialNumber,
            //                CompanyAddress = a.CompanyAddress,
            //                PostalCode = a.PostalCode,
            //                Linkman = a.Linkman,
            //                CompanyTel = a.CompanyTel,
            //                FaxNumber = a.FaxNumber,
            //                EnglishName = b.EnglishName,
            //                Cooperation = b.Cooperation,
            //                CountryId = c.CId,
            //                CountryName = c.CName,
            //                ProvinceId = d.CId,
            //                ProvinceName = d.CName,
            //                CityId = e.CId,
            //                CityName = e.CName,
            //                TypeId = b.TypeId,
            //                IndustyId = b.IndustyId,
            //                Embranchment = b.Embranchment,
            //                HomePage = b.HomePage,
            //                RelationDepartment = b.RelationDepartment,
            //                RelationTime = b.RelationTime,
            //                CreditRatingsId = b.CreditRatingsId,
            //                IntimacyId = b.IntimacyId,
            //                BankName = b.BankName,
            //                BankAccount = b.BankAccount,
            //                EnterpriseCode = b.EnterpriseCode,
            //                Member = b.Member,
            //                TaxpayerCode = b.TaxpayerCode,
            //                Remark = b.Remark,
            //                CooperationName = f.DictionariesName,
            //                IndustyName = i.DictionariesName,
            //                IntimacyName = j.DictionariesName,
            //                TypeName = k.DictionariesName,
            //                CreditRatingsName = g.DictionariesName,
            //                Email = b.Email,
            //                SerialNumber = l.SerialNumber,
            //                PersonBusinessCall = l.PersonBusinessCall,
            //                PersonBusinessFax = l.PersonBusinessFax,
            //                PersonDepartment = l.PersonDepartment,
            //                PersonEmail = l.PersonEmail,
            //                PersonHomePhone = l.PersonHomePhone,
            //                PersonJob = l.PersonJob,
            //                PersonName = l.PersonName,
            //                PersonPhone = l.PersonPhone,
            //                PersonRemark = l.PersonRemark,
            //                PersonResidentialFax = l.PersonResidentialFax,
            //                PersonTime = l.PersonTime
            //            };
            //if(!string.IsNullOrWhiteSpace(name))
            //{
            //    query = query.Where(m => m.PersonName.Contains(name));
            //}
            //if(beginTime!=null)
            //{
            //    query = query.Where(m => m.PersonTime >= beginTime);
            //}
            //if (endTime != null)
            //{
            //    query = query.Where(m => m.PersonTime <= endTime);
            //}
            //totalcount = query.Count();
            //var list = query.OrderBy(m => m.SerialNumber).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
            //return new ResultData() { Code = 1, TotalCount = totalcount, Data = list };
        }
        /// <summary>
        /// 显示分页查询文件
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="name"></param>
        /// <param name="beginTime"></param>
        /// <param name="endTime"></param>
        /// <param name="totalcount"></param>
        /// <returns></returns>
        public ResultData ShowFile( string name, DateTime? beginTime, DateTime? endTime, out int totalcount, int pageindex = 1, int pagesize = 3)
        {
            using (var conn = new SqlConnection(_configuration.GetConnectionString("MSSQL")))
            {
                var query = $"select *,f.DictionariesName as CooperationName,c.CName as CountryName,d.CName as ProvinceName,e.CName as CityName,g.DictionariesName as CreditRatingsName,h.DictionariesName as IndustyName,i.DictionariesName as IntimacyName,j.DictionariesName as TypeName from Customer a join ExtendInformation b on a.CustomerSerialNumber=b.CustomerSerialNumber join CustomerCity c on b.CountryId=c.CId join CustomerCity d on b.ProvinceId=d.CId join CustomerCity e on b.CityId=e.CId join DictionariesTable f on b.Cooperation=f.DictionariesId join DictionariesTable g on b.CreditRatingsId=g.DictionariesId join DictionariesTable h on b.IndustyId=h.DictionariesId join DictionariesTable i on b.IntimacyId=i.DictionariesId join DictionariesTable j on b.TypeId=j.DictionariesId join Accessory k on b.FileId=k.FileId where 1=1  ";
                if (!string.IsNullOrWhiteSpace(name))
                {
                    query += $" and k.FileName='{name}'";
                }
                if (beginTime != null)
                {
                    query += $" and k.FileTime>='{beginTime}'";
                }
                if (endTime != null)
                {
                    query += $" and b.FileTime<='{endTime}'";
                }

                var list = conn.Query<AccessoryDto>(query).ToList();
                totalcount = list.Count();
                list = list.OrderBy(m => m.FileId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
                return new ResultData() { Code = 1, Data = list, TotalCount = totalcount };
            }
            //var query = from a in _hongStoneContext.customers
            //            join b in _hongStoneContext.extendInformations on a.CustomerId equals b.CustomerId
            //            join c in _hongStoneContext.customerCitys on b.CountryId equals c.CId
            //            join d in _hongStoneContext.customerCitys on b.ProvinceId equals d.CId
            //            join e in _hongStoneContext.customerCitys on b.CityId equals e.CId
            //            join f in _hongStoneContext.dictionariesTables on b.Cooperation equals f.DictionariesId
            //            join g in _hongStoneContext.dictionariesTables on b.CreditRatingsId equals g.DictionariesId
            //            join i in _hongStoneContext.dictionariesTables on b.IndustyId equals i.DictionariesId
            //            join j in _hongStoneContext.dictionariesTables on b.IntimacyId equals j.DictionariesId
            //            join k in _hongStoneContext.dictionariesTables on b.TypeId equals k.DictionariesId
            //            join l in _hongStoneContext.accessorys on b.FileId equals l.FileId
            //            select new AccessoryDto
            //            {
            //                CustomerId = a.CustomerId,
            //                CustomerName = a.CustomerName,
            //                CustomerReferred = a.CustomerReferred,
            //                CustomerSerialNumber = a.CustomerSerialNumber,
            //                CompanyAddress = a.CompanyAddress,
            //                PostalCode = a.PostalCode,
            //                Linkman = a.Linkman,
            //                CompanyTel = a.CompanyTel,
            //                FaxNumber = a.FaxNumber,
            //                EnglishName = b.EnglishName,
            //                Cooperation = b.Cooperation,
            //                CountryId = c.CId,
            //                CountryName = c.CName,
            //                ProvinceId = d.CId,
            //                ProvinceName = d.CName,
            //                CityId = e.CId,
            //                CityName = e.CName,
            //                TypeId = b.TypeId,
            //                IndustyId = b.IndustyId,
            //                Embranchment = b.Embranchment,
            //                HomePage = b.HomePage,
            //                RelationDepartment = b.RelationDepartment,
            //                RelationTime = b.RelationTime,
            //                CreditRatingsId = b.CreditRatingsId,
            //                IntimacyId = b.IntimacyId,
            //                BankName = b.BankName,
            //                BankAccount = b.BankAccount,
            //                EnterpriseCode = b.EnterpriseCode,
            //                Member = b.Member,
            //                TaxpayerCode = b.TaxpayerCode,
            //                Remark = b.Remark,
            //                CooperationName = f.DictionariesName,
            //                IndustyName = i.DictionariesName,
            //                IntimacyName = j.DictionariesName,
            //                TypeName = k.DictionariesName,
            //                CreditRatingsName = g.DictionariesName,
            //                Email = b.Email,
            //                FileId=l.FileId,
            //                FileName=l.FileName,
            //                FileSize=l.FileSize,
            //                FileTime=l.FileTime,
            //                FileType=l.FileType,
            //                UploadTime=l.UploadTime
            //            };
            //if (!string.IsNullOrWhiteSpace(name))
            //{
            //    query = query.Where(m => m.FileName.Contains(name));
            //}
            //if (beginTime != null)
            //{
            //    query = query.Where(m => m.FileTime >= beginTime);
            //}
            //if (endTime != null)
            //{
            //    query = query.Where(m => m.FileTime <= endTime);
            //}
            //totalcount = query.Count();
            //var list = query.OrderBy(p => p.FileId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
            //return new ResultData() { Code = 1, TotalCount = totalcount, Data = list };
        }
        /// <summary>
        /// 显示文件
        /// </summary>
        /// <returns></returns>
        public ResultData ShowFiles()
        {
            var list = _hongStoneContext.accessorys.AsQueryable();
            return new ResultData() { Code = 1, Data = list };
        }
        /// <summary>
        /// 客户高级查询查询
        /// </summary>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="number"></param>
        /// <param name="name"></param>
        /// <param name="jian"></param>
        /// <param name="addr"></param>
        /// <param name="lian"></param>
        /// <param name="phone"></param>
        /// <param name="sheng"></param>
        /// <param name="shi"></param>
        /// <param name="xian"></param>
        /// <param name="type"></param>
        /// <param name="hang"></param>
        /// <param name="time"></param>
        /// <param name="totalcount"></param>
        /// <returns></returns>
        public ResultData ShowCustomerTotal(int pageindex, int pagesize, string number, string name, string jian, string addr, string lian, string phone, string sheng, string shi, int type, int hang, DateTime? begintime, DateTime? endtime, out int totalcount)
        {
            using (var conn = new SqlConnection(_configuration.GetConnectionString("MSSQL")))
            {
                var query = $"select *,f.DictionariesName as CooperationName,c.CName as CountryName,d.CName as ProvinceName,e.CName as CityName,g.DictionariesName as CreditRatingsName,h.DictionariesName as IndustyName,i.DictionariesName as IntimacyName,j.DictionariesName as TypeName from Customer a join ExtendInformation b on a.CustomerSerialNumber=b.CustomerSerialNumber join CustomerCity c on b.CountryId=c.CId join CustomerCity d on b.ProvinceId=d.CId join CustomerCity e on b.CityId=e.CId join DictionariesTable f on b.Cooperation=f.DictionariesId join DictionariesTable g on b.CreditRatingsId=g.DictionariesId join DictionariesTable h on b.IndustyId=h.DictionariesId join DictionariesTable i on b.IntimacyId=i.DictionariesId join DictionariesTable j on b.TypeId=j.DictionariesId join Accessory k on b.FileId=k.FileId join ResponsiblePerson m on b.SerialNumber=m.SerialNumber where 1=1  ";

                if (!string.IsNullOrWhiteSpace(number))
                {
                    query += $" and b.CustomerSerialNumber='{number}'";
                }
                if (!string.IsNullOrWhiteSpace(name))
                {
                    query += $" and b.CustomerName='{name}'";
                }
                if (!string.IsNullOrWhiteSpace(jian))
                {
                    query += $" and b.CustomerReferred='{jian}'";
                }
                if (!string.IsNullOrWhiteSpace(addr))
                {
                    query += $" and b.CompanyAddress='{addr}'";
                }
                if (!string.IsNullOrWhiteSpace(lian))
                {
                    query += $" and b.Linkman='{lian}'";
                }
                if (!string.IsNullOrWhiteSpace(phone))
                {
                    query += $" and b.CompanyTel='{phone}'";
                }
                if (!string.IsNullOrWhiteSpace(sheng))
                {
                    query += $" and b.ProvinceName='{sheng}'";
                }
                if (!string.IsNullOrWhiteSpace(shi))
                {
                    query += $" and b.CityName='{shi}'";
                }
                if (type > 0)
                {
                    query += $" and b.TypeId='{type}'";
                }
                if (hang > 0)
                {
                    query += $" and b.IndustyId='{hang}'";
                }
                if (begintime != null)
                {
                    query += $" and b.RelationTime>='{begintime}'";
                }
                if (endtime != null)
                {
                    query += $" and b.RelationTime<='{endtime}'";
                }

                var list = conn.Query<CustomerDto>(query).ToList();
                totalcount = list.Count();
                list = list.OrderBy(m => m.CustomerId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
                return new ResultData() { Code = 1, Data = list, TotalCount = totalcount };
            }
            //    var query = from a in _hongStoneContext.customers
            //            join b in _hongStoneContext.extendInformations on a.CustomerId equals b.CustomerId
            //            join c in _hongStoneContext.customerCitys on b.CountryId equals c.CId
            //            join d in _hongStoneContext.customerCitys on b.ProvinceId equals d.CId
            //            join e in _hongStoneContext.customerCitys on b.CityId equals e.CId
            //            join f in _hongStoneContext.dictionariesTables on b.Cooperation equals f.DictionariesId
            //            join g in _hongStoneContext.dictionariesTables on b.CreditRatingsId equals g.DictionariesId
            //            join i in _hongStoneContext.dictionariesTables on b.IndustyId equals i.DictionariesId
            //            join j in _hongStoneContext.dictionariesTables on b.IntimacyId equals j.DictionariesId
            //            join k in _hongStoneContext.dictionariesTables on b.TypeId equals k.DictionariesId
            //            join l in _hongStoneContext.accessorys on b.FileId equals l.FileId
            //            select new CustomerDto
            //            {
            //                CustomerId = a.CustomerId,
            //                CustomerName = a.CustomerName,
            //                CustomerReferred = a.CustomerReferred,
            //                CustomerSerialNumber = a.CustomerSerialNumber,
            //                CompanyAddress = a.CompanyAddress,
            //                PostalCode = a.PostalCode,
            //                Linkman = a.Linkman,
            //                CompanyTel = a.CompanyTel,
            //                FaxNumber = a.FaxNumber,
            //                EnglishName = b.EnglishName,
            //                Cooperation = b.Cooperation,
            //                CountryId = c.CId,
            //                CountryName = c.CName,
            //                ProvinceId = d.CId,
            //                ProvinceName = d.CName,
            //                CityId = e.CId,
            //                CityName = e.CName,
            //                TypeId = b.TypeId,
            //                IndustyId = b.IndustyId,
            //                Embranchment = b.Embranchment,
            //                HomePage = b.HomePage,
            //                RelationDepartment = b.RelationDepartment,
            //                RelationTime = b.RelationTime,
            //                CreditRatingsId = b.CreditRatingsId,
            //                IntimacyId = b.IntimacyId,
            //                BankName = b.BankName,
            //                BankAccount = b.BankAccount,
            //                EnterpriseCode = b.EnterpriseCode,
            //                Member = b.Member,
            //                TaxpayerCode = b.TaxpayerCode,
            //                Remark = b.Remark,
            //                CooperationName = f.DictionariesName,
            //                IndustyName = i.DictionariesName,
            //                IntimacyName = j.DictionariesName,
            //                TypeName = k.DictionariesName,
            //                CreditRatingsName = g.DictionariesName,
            //                Email = b.Email
            //            };
            //if (!string.IsNullOrWhiteSpace(number))
            //{
            //    query = query.Where(m => m.CustomerSerialNumber.Contains(number));
            //}
            //if (!string.IsNullOrWhiteSpace(name))
            //{
            //    query = query.Where(m => m.CustomerName.Contains(name));
            //}
            //if (!string.IsNullOrWhiteSpace(jian))
            //{
            //    query = query.Where(m => m.CustomerReferred.Contains(jian));
            //}
            //if (!string.IsNullOrWhiteSpace(addr))
            //{
            //    query = query.Where(m => m.CompanyAddress.Contains(addr));
            //}
            //if (!string.IsNullOrWhiteSpace(lian))
            //{
            //    query = query.Where(m => m.Linkman.Contains(lian));
            //}
            //if (!string.IsNullOrWhiteSpace(phone))
            //{
            //    query = query.Where(m => m.CompanyTel.Contains(phone));
            //}
            //if (!string.IsNullOrWhiteSpace(sheng))
            //{
            //    query = query.Where(m => m.ProvinceName.Contains(sheng));
            //}
            //if (!string.IsNullOrWhiteSpace(shi))
            //{
            //    query = query.Where(m => m.CityName.Contains(shi));
            //}
            //if (type>0)
            //{
            //    query = query.Where(m => m.TypeId==type);
            //}
            //if (hang > 0)
            //{
            //    query = query.Where(m => m.IndustyId == hang);
            //}
            //if(begintime!=null)
            //{
            //    query = query.Where(m => m.RelationTime>=begintime);
            //}
            //if (endtime != null)
            //{
            //    query = query.Where(m => m.RelationTime <= endtime);
            //}
            //totalcount = query.Count();
            //var list = query.OrderBy(p => p.CustomerId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
            //return new ResultData() { Code = 1, TotalCount = totalcount, Data = list };
        }
        /// <summary>
        /// 批量删除文件
        /// </summary>
        /// <param name="ids"></param>
        /// <returns></returns>
        public ResultData DelProject(string ids)
        {
            var id = ids.Split(',');
            foreach (var item in id)
            {
                var obj = _hongStoneContext.accessorys.FirstOrDefault(m => m.FileId == item);
                if (obj != null)
                {
                    _hongStoneContext.accessorys.Remove(obj);
                }
            }
            return new ResultData() { Code = _hongStoneContext.SaveChanges() };
        }
        /// <summary>
        /// 显示列表
        /// </summary>
        /// <returns></returns>
        public ResultData ShowCheckList()
        {
            //Dictionary<string, string> dict = new Dictionary<string, string>();
            List<TiaoJianDto> dict = new List<TiaoJianDto>();
            PropertyInfo[] properties = typeof(CustomerDto).GetProperties(BindingFlags.Public | BindingFlags.Instance);
            foreach (PropertyInfo property in properties)
            {
                TiaoJianDto kk = new TiaoJianDto();
                var xian = property.GetCustomAttributes(typeof(DescriptionAttribute), true);
                if(xian.Length>0)
                {
                    kk.Name = property.Name;
                    kk.Tiao = ((DescriptionAttribute)xian[0]).Description;
                    dict.Add(kk);
                }
            }
            return new ResultData() {Code=1,Data=dict };
        }
        /// <summary>
        /// 反射
        /// </summary>
        /// <returns></returns>
        public ResultData ShowCheckListCheck()
        {
            //获取运行时类型信息Reflection
            //Dictionary<string, string> dict = new Dictionary<string, string>();
            //实例化一个对象
            List<TiaoJianDto> dict = new List<TiaoJianDto>();
            //通过PropertyInfo获取属性名
            PropertyInfo[] properties = typeof(CheckDto).GetProperties(BindingFlags.Public | BindingFlags.Instance);
            //循环
            foreach (PropertyInfo property in properties)
            {
                //实例化一个Dto类，用来存储获取的属性名
                TiaoJianDto kk = new TiaoJianDto();
                var xian = property.GetCustomAttributes(typeof(DescriptionAttribute), true);
                //判断不为空，然后赋值添加
                if (xian.Length > 0)
                {
                    kk.Name = property.Name;
                    kk.Tiao = ((DescriptionAttribute)xian[0]).Description;
                    dict.Add(kk);
                }
            }
            return new ResultData() { Code = 1, Data = dict };
        }
        /// <summary>
        /// 显示录入列表
        /// </summary>
        /// <param name="checkDto"></param>
        /// <param name="pageindex"></param>
        /// <param name="pagesize"></param>
        /// <param name="totalcount"></param>
        /// <returns></returns>
        public ResultData ShowLists(int pageindex, int pagesize, out int totalcount)
        {
            var query = from a in _hongStoneContext.customers
                        join b in _hongStoneContext.extendInformations on a.CustomerId equals b.CustomerId
                        join c in _hongStoneContext.customerCitys on b.CountryId equals c.CId
                        join d in _hongStoneContext.customerCitys on b.ProvinceId equals d.CId
                        join e in _hongStoneContext.customerCitys on b.CityId equals e.CId
                        join f in _hongStoneContext.dictionariesTables on b.Cooperation equals f.DictionariesId
                        join g in _hongStoneContext.dictionariesTables on b.CreditRatingsId equals g.DictionariesId
                        join i in _hongStoneContext.dictionariesTables on b.IndustyId equals i.DictionariesId
                        join j in _hongStoneContext.dictionariesTables on b.IntimacyId equals j.DictionariesId
                        join k in _hongStoneContext.dictionariesTables on b.TypeId equals k.DictionariesId
                        select new CustomerDto
                        {
                            CustomerId = a.CustomerId,
                            CustomerName = a.CustomerName,
                            CustomerReferred = a.CustomerReferred,
                            CustomerSerialNumber = a.CustomerSerialNumber,
                            CompanyAddress = a.CompanyAddress,
                            PostalCode = a.PostalCode,
                            Linkman = a.Linkman,
                            CompanyTel = a.CompanyTel,
                            FaxNumber = a.FaxNumber,
                            EnglishName = b.EnglishName,
                            Cooperation = b.Cooperation,
                            CountryId = c.CId,
                            CountryName = c.CName,
                            ProvinceId = d.CId,
                            ProvinceName = d.CName,
                            CityId = e.CId,
                            CityName = e.CName,
                            TypeId = b.TypeId,
                            IndustyId = b.IndustyId,
                            Embranchment = b.Embranchment,
                            HomePage = b.HomePage,
                            RelationDepartment = b.RelationDepartment,
                            RelationTime = b.RelationTime,
                            CreditRatingsId = b.CreditRatingsId,
                            IntimacyId = b.IntimacyId,
                            BankName = b.BankName,
                            BankAccount = b.BankAccount,
                            EnterpriseCode = b.EnterpriseCode,
                            Member = b.Member,
                            TaxpayerCode = b.TaxpayerCode,
                            Remark = b.Remark,
                            CooperationName = f.DictionariesName,
                            IndustyName = i.DictionariesName,
                            IntimacyName = j.DictionariesName,
                            TypeName = k.DictionariesName,
                            CreditRatingsName = g.DictionariesName,
                            Email = b.Email
                        };
           
            totalcount = query.Count();
            var liet = query.OrderBy(m => m.CustomerId).Skip((pageindex - 1) * pagesize).Take(pagesize).ToList();
            return new ResultData() { Code = 1, TotalCount = totalcount, Data = liet };

        }
    }
}
